/* eslint-disable react/no-children-prop */
import { Route, RouteChildrenProps, RouteProps } from 'react-router'
type Props = RouteProps
export default function KeepAlive ({ path, children, ...rest }: Props) {
  const child = (props: RouteChildrenProps) => {
    console.log('child....', props)
    // const isMatch = props.location.pathname.startsWith(path as string)
    return (
      <div
        className="keep-alive"
        style={{ display: props.match ? 'block' : 'none' }}>
        {children}
      </div>
    )
  }
  return <Route path={path} {...rest} children={child} />
}
